package io.jt808.proto.rsp;

import io.norland.buffer.AutoBuffer;
import io.norland.annotations.Proto;
import io.norland.proto.IProto;
import lombok.Data;

/**
 * 平台通用应答
 */
@Proto("8001")
@Data
public class JT8001 implements IProto {

    /**
     * 应答消息流水号
     */
    private short responseMessageSerialNo;
    /**
     * 应答消息ID
     */
    private int responseMessageId;
    /**
     * 应答结果，0：成功/确认；1：失败；2：消息有误；3：不支持；4：报警处理确认；
     */
    private byte responseResult;

    public byte[] writeToBytes() {
        AutoBuffer buff = new AutoBuffer();
        buff.writeShort(responseMessageSerialNo);
        buff.writeShort(responseMessageId);
        buff.writeByte(responseResult);
        return buff.array();
    }

    @Override
    public void readFromBuf(AutoBuffer buf) {
        responseMessageSerialNo = buf.readShort();
        responseMessageId = buf.readShort();
        responseResult = buf.readByte();
    }
}